package jp.go.aist.six.util.web;

import jp.go.aist.six.util.repository.QueryParams;



/**
 *
 * @author  Akihito Nakamura, AIST
 * @version $Id: UrlUtil.java 563 2013-04-12 10:38:15Z nakamura5akihito@gmail.com $
 */
public class UrlUtil
{

    /**
     *
     * @param params
     * @return
     */
    public static String toString(
                    final QueryParams params
                    )
    {
        if (params == null  ||  params.size() == 0) {
            return "";
        }

        StringBuilder  s = new StringBuilder();
        boolean  first_key = true;
        for (String  key : params.keys()) {
            if (first_key) {
                s.append( "?" );
                first_key = false;
            } else {
                s.append( "&" );
            }

            String  value = params.get( key );
            s.append( key ).append( "=" ).append( value );
        }

        return s.toString();
    }

}
//
